
	function brand($field, $value, $fieldinfo) {
		//品牌
		$brand_db = pc_base::load_model('brand_model');
		$brand_1 = $brand_db->select(array('catid'=>$this->catid, 'parentid'=>0), 'id,name', '', 'name ASC');
		if (is_array($brand_1)) {
			foreach ($brand_1 as &$b){
				$b['child'] = $brand_db->select(array('catid'=>$this->catid, 'parentid'=>$b['id']), 'id,name', '', 'name ASC');
			}
		}

		if(intval($value) > 0) {
			$brand = $brand_db->get_one('`id`='.$value, 'id,name,parentid');
			if ($brand['parentid'] == 0) {
				$parent_brand = $brand;
			} else {
				//$brand = $brand_db->get_one('`id`='.$arrvalue[1], 'id,name,parentid');
				$parent_brand = $brand_db->get_one('`id`='.$brand['parentid'], 'id,name');
			}
		}
		
		$str = $str2 = '';
		if($brand_1) {
			$str = '<select name="info['.$field.'][]" id="brand_1">';
			foreach($brand_1 AS $b1) {
	            $str .= "<option value='".$b1['id']."' ".(isset($parent_brand['id']) &&  $parent_brand['id']==$b1['id'] ? "selected":"").">".$b1['name']."</option>";
	        }
	        
	        if ($parent_brand != $brand) {
	        	$str2 .= '<select name="info['.$field.'][]" id="brand_2">';
		        foreach($brand_1 AS $b1) {
		            if($b1['id'] == $parent_brand['id']) {
		        		foreach($b1['child'] AS $b2) {
		           			$str2 .= "<option value='".$b2['id']."' ".(isset($brand['id']) && $brand['id']==$b2['id'] ? "selected":"").">".$b2['name']."</option>";
		       			}
		            }
		        }
	        } else {
	        	$str2 .= '<select name="info['.$field.'][]" id="brand_2" '.((isset($brand_1[0]['child']) && $brand_1[0]['child'] && !$value) ? '' : 'style="display:none;"').'>';
	        	foreach($brand_1[0]['child'] AS $b2) {
           			$str2 .= "<option value='".$b2['id']."'>".$b2['name']."</option>";
       			}
	        }
	        $str .= '</select>';
	        $str2 .= '</select>';
		} else {
			return "<span class='red'>此栏目暂时没有关联品牌</span>";
		}
		
		$js = '<script type="text/javascript">
var brands = '.json_encode($brand_1).';
$(function(){
	$("#brand_1").change(function(){
		var bid_1 = this.value;
		var html="";
		for(i in brands) {
			if(brands[i].id == bid_1) {
				for(j in brands[i].child) {
					html += "<option value=\'"+brands[i].child[j].id+"\'>"+brands[i].child[j].name+"</option>";
				}
				if(html=="") {
					$("#brand_2").html(html).hide();
				}else {
					$("#brand_2").show().html(html);
				}
			}
		}
	});
});
</script>';
		return $str.$str2.$js;
	}
